﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace HCQ2_Model.VRQDMeta.InputDto._20220112
{
    /// <summary>
    ///  发布应用商品信息
    /// </summary>
    public class MetaAppInfoInput
    {
        /// <summary>
        ///  用户编码
        /// </summary>
        [Required(ErrorMessage = "用户编码必传！")]
        public string userid { get; set; }
        /// <summary>
        ///  应用商品ID
        /// </summary>
        public int fileID { get; set; }
        /// <summary>
        ///  名称
        /// </summary>
        [Required(ErrorMessage = "名称必传！")]
        public string fileName { get; set; }
        /// <summary>
        ///  简介
        /// </summary>
        public string fileNote { get; set; }
        /// <summary>
        ///  最大人数
        /// </summary>
        [Required(ErrorMessage = "最大人数必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入最大人数")]
        public int playerNum { get; set; }
        /// <summary>
        ///  最大时长，数字型，单位：秒【整型】
        /// </summary>
        public int timeSpan { get; set; }
        /// <summary>
        ///  所属目录ID
        /// </summary>
        [Required(ErrorMessage = "所属目录ID必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入所属目录ID")]
        public int folderID { get; set; }
        /// <summary>
        ///  应用附件在文件服务器的访问地址
        /// </summary>
        [Required(ErrorMessage = "应用附件地址必传！")]
        public string attachUrl { get; set; }
        /// <summary>
        ///  应用缩略图在文件服务器的访问地址
        /// </summary>
        [Required(ErrorMessage = "应用缩略图地址必传！")]
        public string imageUrl { get; set; }
        /// <summary>
        ///  版本号
        /// </summary>
        [Required(ErrorMessage = "版本号必传！")]
        public string verNumber { get; set; }
        /// <summary>
        ///  版本更新说明
        /// </summary>
        public string versionNote { get; set; }
        /// <summary>
        ///  应用大小，数字型，单位：Kb
        /// </summary>
        [Required(ErrorMessage = "应用大小必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入应用大小")]
        public int appSize { get; set; }
        /// <summary>
        ///  价格明细
        /// </summary>
        [Required(ErrorMessage = "价格明细必传！")]
        public List<PriceMoney> listPrice { get; set; }
        /// <summary>
        /// 转T_DocumentInfo实体
        /// </summary>
        /// <returns></returns>
        public T_DocumentInfo ToDocInfoEntity()
        {
            return new T_DocumentInfo
            {
                file_name = this.fileName,
                file_note = this.fileNote,
                pag_num = this.playerNum,
                finish_time = this.timeSpan, //(int)(this.timeSpan * 60 * 60),
                store_id = this.folderID,
                attach_url = this.attachUrl,
                image_url = this.imageUrl,
                doc_number = this.verNumber,
                file_size = this.appSize,
                file_classify = "",
                doc_type = "",
                create_time = System.DateTime.Now,
                update_time = System.DateTime.Now,
                pro_type = 6,
                page_type = "QDMetaProgram",
                isEntity = false,
                file_status = 1
            };
        }
        /// <summary>
        /// 转T_DocumentInfoLog实体
        /// </summary>
        /// <returns></returns>
        public T_DocumentInfoLog ToDocInfoLogEntity()
        {
            return new T_DocumentInfoLog
            {
                file_name = this.fileName,
                file_note = this.fileNote,
                pag_num = this.playerNum,
                finish_time = this.timeSpan, //(int)(this.timeSpan * 60 * 60),
                store_id = this.folderID,
                attach_url = this.attachUrl,
                image_url = this.imageUrl,
                doc_number = this.verNumber,
                file_size = this.appSize,
                create_time = System.DateTime.Now,
                update_time = System.DateTime.Now,
                pro_type = 6,
                page_type = "QDMetaProgram",
                isEntity = false,
                file_status = 1,
                folder_id = this.folderID,
                versionNote = this.versionNote
            };
        }
    }
}